#ifndef GLSHADERMANAGER_H
#define GLSHADERMANAGER_H

#include "glshader.h"
#include <map>
#include <string>

class glShaderManager
{
public:
    static glShaderManager* getInstance();
    static void deleteInstance();

    virtual ~glShaderManager();

    // Regular GLSL (Vertex+Fragment Shader)
    glShader* loadfromFile(char* vertexFile, char* fragmentFile);    //!< load vertex/fragment shader from file. If you specify 0 for one of the shaders, the fixed function pipeline is used for that part. \param vertexFile Vertex Shader File. \param fragmentFile Fragment Shader File.
    glShader* loadfromMemory(const char* vertexMem, const char* fragmentMem); //!< load vertex/fragment shader from memory. If you specify 0 for one of the shaders, the fixed function pipeline is used for that part.

    // With Geometry Shader (Vertex+Geomentry+Fragment Shader)
    glShader* loadfromFile(std::string name, char* vertexFile, char* geometryFile, char* fragmentFile); //!< load vertex/geometry/fragment shader from file. If you specify 0 for one of the shaders, the fixed function pipeline is used for that part. \param vertexFile Vertex Shader File. \param geometryFile Geometry Shader File \param fragmentFile Fragment Shader File.
    glShader* loadfromMemory(const char* vertexMem, const char* geometryMem, const char* fragmentMem); //!< load vertex/geometry/fragment shader from memory. If you specify 0 for one of the shaders, the fixed function pipeline is used for that part.

    void      SetInputPrimitiveType(int nInputPrimitiveType);    //!< Set the input primitive type for the geometry shader \param nInputPrimitiveType Input Primitive Type, for example GL_TRIANGLES
    void      SetOutputPrimitiveType(int nOutputPrimitiveType);  //!< Set the output primitive type for the geometry shader \param nOutputPrimitiveType Output Primitive Type, for example GL_TRIANGLE_STRIP
    void      SetVerticesOut(int nVerticesOut);                  //!< Set the maximal number of vertices the geometry shader can output \param nVerticesOut Maximal number of output vertices. It is possible to output less vertices!

    bool      free(glShader* o); //!< Remove the shader and free the memory occupied by this shader.
    glShader* operator[](const std::string &programname);

private:
    glShaderManager();
    static glShaderManager* pInstance;

    std::vector<glShader*>  _shaderObjectList;
    int                     _nInputPrimitiveType;
    int                     _nOutputPrimitiveType;
    int                     _nVerticesOut;

    std::map<std::string, glShader*> m_shaderPrograms;
};

#endif // GLSHADERMANAGER_H
